<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>输血管理系统</title>
    <link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="/element-theme/blue/index.css">
</head>
<body>
<div class="data-manage-table">
    <template>
        <el-form ref="form" :inline="true" style="padding:20px 20px 0 20px;">
            <el-row>

           <el-col :span="8">
            <el-form-item  label="姓名" >
                <el-input placeholder="请输入患者姓名" v-model="pagination.name" >
                </el-input>
            </el-form-item></el-col>
                <el-col :span="8">
            <el-form-item  label="病历号">
                <el-input placeholder="请输入患者病历号" v-model="pagination.medicalRecordNumber">
                </el-input>
            </el-form-item></el-col>
                <el-col :span="8">
            <el-form-item label="身份证号">
                <el-input  placeholder="请输入患者身份证号" v-model="pagination.idcard">
                </el-input>
            </el-form-item></el-col>
            </el-row>
            <el-form-item>
                <el-button type="primary" @click="getByQueryPage(1)">搜索</el-button>
                <el-button type="primary" @click="add">新增</el-button>
                <el-button type="primary" @click="batchDelete">删除</el-button>
                <el-button type="info" @click="getByQueryPage()">重置</el-button>
                <el-button type="primary" @click="transfusion">输血申请</el-button>
            </el-form-item>
        </el-form>

        <el-dialog title="输血申请类型选择" center :visible.sync="dialogTranVisible" width="45%" @close="cancel">
            <el-form ref="form"   label-width="100px" inline align="center" style="-webkit-border-vertical-spacing: 13px">
            <el-row><el-button type="primary" @click="clinic" >临床输血申请</el-button></el-row>
            <el-button type="primary" @click="auto" >自体输血申请</el-button>
            <el-row><el-button type="primary" @click="surgey" >术中输血申请</el-button></el-row>
            </el-form>
        </el-dialog>

        <el-dialog title="添加患者信息" center :visible.sync="dialogVisible" width="75%" @close="cancel" >
            <!-- 内容的主体区域 -->
            <el-form ref="form" :model="addForm" :rules="addFormRules"  align="center" >
                <el-descriptions   :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"  :size="size" border>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            身份证号
                        </template>
                    <el-form-item  prop="idcard" >
                    <el-input  v-model="addForm.idcard" maxlength="18"  show-word-limit ></el-input>
                    </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            姓名
                        </template>
                <el-form-item prop="name">
                    <el-input v-model="addForm.name" style="width:200px" >
                    </el-input></el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            性别
                        </template>
                    <el-form-item  prop="gender">
                        <el-select v-model="addForm.gender" style="width:200px">
                            <el-option v-for="item in location" :key="item.value" :label="item.label"
                                       :value="item.value" >
                            </el-option>
                        </el-select>
                    </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            年龄
                        </template>
                <el-form-item  prop="age">
                    <el-input-number v-model="addForm.age" controls-position="right" @change="handleChange" :min="1" :max="100" style="width:200px"></el-input-number>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            民族
                        </template>
                <el-form-item  prop="nationality">
                    <el-select v-model="addForm.nationality" placeholder="请选择民族" filterable  style="width:200px">
                        <el-option v-for="item in optionNationality" :key="item.code" :label="item.name"
                                   :value="item.code" width="50px">
                        </el-option>
                    </el-select>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            科别
                        </template>
                    <el-form-item prop="department">
                        <el-select v-model="departmentSample.code"  @change="getDcode()" clearable placeholder="请选择一级科室" filterable style="width:100px">
                            <el-option v-for="item in parentDepartmentGroups" :label="item.name" :key="item.code" :value="item.code"></el-option>
                        </el-select>
                        <el-select v-model="addForm.department" clearable placeholder="请选择二级科室" filterable style="width:100px">
                            <el-option v-for="item in childDepartmentGroups" :label="item.name" :key="item.code" :value="item.name"></el-option>
                        </el-select>
                    </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            床号
                        </template>
                <el-form-item  prop="bedNumber">
                    <el-input v-model="addForm.bedNumber" ></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            既往病史
                        </template>
                <el-form-item  prop="medicalHistory">
                    <el-input v-model="addForm.medicalHistory" ></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            既往输血史
                        </template>
                    <el-form-item  prop="tansfusionHistory">
                        <el-input v-model="addForm.tansfusionHistory" ></el-input>
                    </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            孕次数
                        </template>
                <el-form-item prop="prengancy">
                    <el-input-number v-model="addForm.prengancy" controls-position="right" @change="handleChange" :min="0" :max="100" style="width:200px"></el-input-number>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            产次数
                        </template>
                <el-form-item  prop="production">
                    <el-input-number v-model="addForm.production" controls-position="right" @change="handleChange" :min="0" :max="100" style="width:200px"></el-input-number>
                </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            单位
                        </template>
                <el-form-item  prop="unit">
                    <el-input v-model="addForm.unit"></el-input>
                </el-form-item></el-descriptions-item>
                    <el-descriptions-item>

                        <template slot="label" align="center" >
                            属地
                        </template>
                        <el-form-item  prop="territorial">
                            <el-cascader
                                    :options="options"
                                    v-model="selectedOptions"
                                    @change="handleChange1"
                                    style="width: 300px"
                            ></el-cascader>
                        </el-form-item>
                        </el-descriptions-item>


                </el-descriptions>


            </el-form>
            <!-- 底部区域 -->

            <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel()">取 消</el-button>
                    <el-button type="primary" @click="save">确 定</el-button>
                </span>

        </el-dialog>

        <el-dialog title="修改患者信息" center :visible.sync="dialogUpdateVisible" width="75%" @close="cancel" >
            <!-- 内容的主体区域 -->
            <el-form ref="form" :model="updateForm" :rules="addFormRules"  align="center" >
                <el-descriptions   :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"  :size="size" border>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            身份证号
                        </template>
                        <el-form-item  prop="idcard" >
                            <el-input  v-model="updateForm.idcard" maxlength="18"  show-word-limit ></el-input>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            姓名
                        </template>
                        <el-form-item prop="name">
                            <el-input v-model="updateForm.name" style="width:200px" >
                            </el-input></el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            性别
                        </template>
                        <el-form-item  prop="gender">
                            <el-select v-model="updateForm.gender" style="width:200px">
                                <el-option v-for="item in location" :key="item.value" :label="item.label"
                                           :value="item.value" >
                                </el-option>
                            </el-select>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            年龄
                        </template>
                        <el-form-item  prop="age">
                            <el-input-number v-model="updateForm.age" controls-position="right" @change="handleChange" :min="1" :max="100" style="width:200px"></el-input-number>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            民族
                        </template>
                        <el-form-item  prop="nationality">
                            <el-select v-model="updateForm.nationality" placeholder="请选择民族" filterable  style="width:200px">
                                <el-option v-for="item in optionNationality" :key="item.code" :label="item.name"
                                           :value="item.code" width="50px">
                                </el-option>
                            </el-select>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            科别
                        </template>
                        <el-form-item prop="department">
                            <el-select v-model="departmentSample.code"  @change="getDcode()" clearable placeholder="请选择一级科室" filterable style="width:100px">
                                <el-option v-for="item in parentDepartmentGroups" :label="item.name" :key="item.code" :value="item.code"></el-option>
                            </el-select>
                            <el-select v-model="updateForm.department" clearable placeholder="请选择二级科室" filterable style="width:100px">
                                <el-option v-for="item in childDepartmentGroups" :label="item.name" :key="item.code" :value="item.name"></el-option>
                            </el-select>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            床号
                        </template>
                        <el-form-item  prop="bedNumber">
                            <el-input v-model="updateForm.bedNumber" ></el-input>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            既往病史
                        </template>
                        <el-form-item  prop="medicalHistory">
                            <el-input v-model="updateForm.medicalHistory" ></el-input>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            既往输血史
                        </template>
                        <el-form-item  prop="tansfusionHistory">
                            <el-input v-model="updateForm.tansfusionHistory" ></el-input>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            孕次数
                        </template>
                        <el-form-item prop="prengancy">
                            <el-input-number v-model="updateForm.prengancy" controls-position="right" @change="handleChange" :min="0" :max="100" style="width:200px"></el-input-number>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            产次数
                        </template>
                        <el-form-item  prop="production">
                            <el-input-number v-model="updateForm.production" controls-position="right" @change="handleChange" :min="0" :max="100" style="width:200px"></el-input-number>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            单位
                        </template>
                        <el-form-item  prop="unit">
                            <el-input v-model="updateForm.unit"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            属地
                        </template>
                        <el-form-item  prop="territorial">
                            <el-cascader
                                    :options="options"
                                    v-model="selectedOptions"
                                    @change="handleChange1"
                                    style="width: 300px">
                            </el-cascader>
                        </el-form-item>
                    </el-descriptions-item>
                </el-descriptions>


            </el-form>
            <!-- 底部区域 -->

            <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel()">取 消</el-button>
                    <el-button type="primary" @click="updatePatient">确 定</el-button>
                </span>

        </el-dialog>

        <el-dialog title="患者基本信息" center :visible.sync="dialogPatientVisible" width="60%" @close="cancel">
            <el-descriptions   :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"  :size="size" border>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        病历号
                    </template>
                    {{ addForm.medicalRecordNumber }}</el-descriptions-item>
                    <el-descriptions-item>
                    <template slot="label" align="center" >
                    身份证号
                </template>
                    {{ addForm.idcard }}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        姓名
                    </template>
                    {{ addForm.name }}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        性别
                    </template>
                    {{addForm.gender}}
                </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        年龄
                    </template>
                    {{ addForm.age }}</el-descriptions-item>

            <el-descriptions-item>
                <template slot="label" align="center">
                    民族
                </template>
                {{ getNationalityName(addForm.nationality)}}</el-descriptions-item>
            <el-descriptions-item>
                <template slot="label" align="center" >
                    科别
                </template>
                {{ addForm.department }}</el-descriptions-item>
            <el-descriptions-item>
                <template slot="label" align="center" >
                    床号
                </template>
                {{ addForm.bedNumber }}</el-descriptions-item>
            <el-descriptions-item>
                <template slot="label" align="center" >
                    既往病史
                </template>
                {{ addForm.medicalHistory }}</el-descriptions-item>
            <el-descriptions-item>
                <template slot="label" align="center" >
                    既往输血史
                </template>
                {{ addForm.tansfusionHistory }}</el-descriptions-item>
            <el-descriptions-item>
                <template slot="label" align="center" >
                    孕次数
                </template>
                {{ addForm.prengancy }}</el-descriptions-item>
            <el-descriptions-item>
            <template slot="label" align="center" >
                产次数
            </template>
            {{ addForm.production }}</el-descriptions-item>
            <el-descriptions-item>
                <template slot="label" align="center" >
                    属地
                </template>
                {{ addForm.territorial }}</el-descriptions-item>
            <el-descriptions-item>
                <template slot="label" align="center" >
                    单位
                </template>
                {{ addForm.unit }}</el-descriptions-item>
            </el-descriptions>


        </el-dialog>
        <el-dialog title="临床输血申请" center :visible.sync="dialogClinicVisible" width="1250px" @close="cancel" >
            <el-form ref="form" :model="clinicSample" :rules="clinicFormRules" >

            <el-descriptions   :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"  :size="size" border>

                <el-descriptions-item>
                    <template slot="label" align="center" >
                        病历号
                    </template>
                    <el-form-item prop="medicalRecordNumber">
                    <el-input  type="text" id="a" placeholder="请输入患者病案号" v-model="clinicSample.medicalRecordNumber" @change="getClinicIdcard()"></el-input>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item>

                    <template slot="label" align="center" >
                        受血者身份证号
                    </template>
                    <el-form-item prop="patientIdcard">
                        <el-input type="text" placeholder="请输入受血者身份证号" v-model="clinicSample.patientIdcard" maxlength="18"  show-word-limit ></el-input></el-form-item></el-descriptions-item>

                    <el-descriptions-item>

                    <template slot="label" align="center" >
                        受血者血样检验信息单号
                    </template>
                        <el-form-item prop="inspectionSheet">
                <el-input type="text" placeholder="请输入受血者血样检验信息单号" v-model="bloodTestSample.inspectionSheet" @change="bloodInfo()"></el-input>
                        </el-form-item>
                    </el-descriptions-item>
                <el-descriptions-item>

                    <template slot="label" align="center" >
                        临床诊断
                    </template>
                    <el-form-item prop="clinicalDiagnosis">
                    <el-select v-model="clinicSample.clinicalDiagnosis" placeholder="请选择临床诊断" filterable >
                        <el-option v-for="(item,index) in optionDiagnosis" :key="index" :label="item.name"
                                   :value="item.name" width="50px">
                        </el-option>
                    </el-select>
                    </el-form-item>
                    </el-descriptions-item>
                <el-descriptions-item>

                    <template slot="label" align="center" >
                        输血目的
                    </template>
                    <el-form-item prop="transfusionPurpose">
                        <el-input type="text"  placeholder="请输入输血目的" v-model="clinicSample.transfusionPurpose" ></el-input></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        输血成分
                    </template>
                    <el-form-item prop="transfusionType">
                    <el-select v-model="clinicSample.transfusionType" placeholder="请选择输血成分" filterable >
                        <el-option v-for="item in optionTransfusionType" :key="item.code" :label="item.name"
                                   :value="item.code" width="50px">
                        </el-option>
                    </el-select></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        申请输血量
                    </template>
                    <el-form-item prop="transfusionVolume">
                    <el-select v-model="clinicSample.transfusionVolume" placeholder="请选择申请输血量" filterable >
                        <el-option v-for="item in bloodSizeList" :key="item.code" :label="item.size"
                                   :value="item.code" width="50px">
                        </el-option>
                    </el-select></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        预定输血日期
                    </template>
                    <el-form-item prop="scheduledTransfusionTime">
                    <el-date-picker
                            v-model="clinicSample.scheduledTransfusionTime"
                            type="date"
                            placeholder="选择日期"
                            size="small"
                            format="yyyy-MM-dd HH:mm:ss"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            style="width: 180px">
                    </el-date-picker></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        辐照血
                    </template>
                    <el-form-item prop="isIrradiationBlood">
                    <el-select v-model="clinicSample.isIrradiationBlood" style="width: 100px">
                        <el-option v-for="item in options1" :key="item.value" :label="item.label"
                                   :value="item.value"></el-option>
                    </el-select></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        过滤血
                    </template>
                    <el-form-item prop="isFilteringBlood">
                    <el-select v-model="clinicSample.isFilteringBlood" style="width: 100px">
                        <el-option v-for="item in options1" :key="item.value" :label="item.label"
                                   :value="item.value"></el-option>
                    </el-select></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        复检
                    </template>
                    <el-form-item prop="isRecheck">
                    <el-select v-model="clinicSample.isRecheck" style="width: 100px">
                        <el-option v-for="item in options1" :key="item.value" :label="item.label"
                                   :value="item.value"></el-option>
                    </el-select></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        接受标本时间
                    </template>
                    <el-form-item prop="acceptSampleTime">
                    <el-date-picker
                            v-model="clinicSample.acceptSampleTime"
                            type="date"
                            placeholder="选择日期"
                            size="small"
                            format="yyyy-MM-dd HH:mm:ss"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            style="width: 180px">
                    </el-date-picker>
                    </el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        申请医生
                    </template>
                    <el-form-item prop="applyDoctor">
                        <el-input placeholder="请输入申请医师" v-model="clinicSample.applyDoctor"  @focus="getUser()"style="width: 180px"></el-input></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        主治医师
                    </template>
                    <el-form-item prop="attendingPhysician">
                        <el-input placeholder="请输入主治医师" v-model="clinicSample.attendingPhysician" style="width: 180px"></el-input></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        申请日期
                    </template>
                    <el-form-item prop="applyTime">
                    <el-date-picker
                            v-model="clinicSample.applyTime"
                            type="date"
                            placeholder="选择日期"
                            size="small"
                            format="yyyy-MM-dd HH:mm:ss"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            style="width: 180px">
                    </el-date-picker></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        输血同意书
                    </template>
                    <el-form-item prop="isSignConsentForm">
                    <el-select v-model="clinicSample.isSignConsentForm" style="width: 180px">
                        <el-option label="已签" value="1"></el-option>
                        <el-option label="未签" value="0"></el-option>
                    </el-select></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        受血者血液标本
                    </template>
                    <el-form-item prop="recipientSpecimen">
                    <el-select v-model="clinicSample.recipientSpecimen" style="width: 180px">
                        <el-option label="有" value="1"></el-option>
                        <el-option label="已抽血未回" value="0"></el-option>
                    </el-select></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        接收标本时间
                    </template>
                    <el-form-item prop="receiveSampleTime">
                    <el-date-picker
                            v-model="clinicSample.receiveSampleTime"
                            type="date"
                            placeholder="选择日期"
                            size="small"
                            format="yyyy-MM-dd HH:mm:ss"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            style="width: 180px">
                    </el-date-picker></el-form-item></el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        受血者ABO血型
                    </template>
                    {{getABOName(bloodSample.bloodType)}} </el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        受血者Rh（D）血型
                    </template>
                    {{getRhName(bloodSample.rhd)}}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        谷丙转氨酶
                    </template>
                    {{bloodSample.alt }}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        红细胞
                    </template>
                    {{ bloodSample.rbc}}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        乙肝表面抗原
                    </template>
                        {{ bloodSample.hbsag}}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        血红蛋白
                    </template>
                    {{ bloodSample.hb}}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        丙肝抗体
                    </template>
                        {{bloodSample.hcv }}</el-descriptions-item>
                <el-descriptions-item>
                    <template slot="label" align="center" >
                        血小板
                    </template>
                        {{bloodSample.plt }}</el-descriptions-item>
                <el-descriptions-item>

                    <template slot="label" align="center" >
                        梅毒
                    </template>
                    {{ bloodSample.rpr}}</el-descriptions-item>


            </el-descriptions>  </el-form>
            <!-- 底部区域 -->
            <span slot="footer" class="dialog-footer">
            <el-button @click="cancel()">取 消</el-button>
            <el-button type="primary" @click="saveClinic">申 请</el-button>
                </span>


        </el-dialog>

        <el-dialog title="自体输血申请" center :visible.sync="dialogAutoVisible" width="75%" @close="cancel">
            <el-form ref="form" :model="autoSample" :rules="autoFormRules" >
            <!-- 内容的主体区域 -->
                <el-descriptions   :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"   border>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            病历号
                        </template>
                        <el-form-item prop="medicalRecordNumber">
                            <el-input placeholder="请输入受血者病历号" v-model="autoSample.medicalRecordNumber" @change="getIdcard()"></el-input></el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            身份证号
                        </template>
                        <el-form-item prop="patientIdcard">
                        <el-input placeholder="请输入受血者身份证号" v-model="autoSample.patientIdcard" maxlength="18"  show-word-limit></el-input>
                        </el-form-item>
                    </el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            临床诊断
                        </template>
                        <el-form-item prop="diagnosisResult">
                        <el-select v-model="autoSample.diagnosisResult" placeholder="请选择临床诊断" filterable >
                            <el-option v-for="(item,index) in optionDiagnosis" :key="index" :label="item.name"
                                       :value="item.name" width="50px">
                            </el-option>
                        </el-select>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            输血成分
                        </template>
                        <el-form-item prop="transfusionType">
                    <el-select v-model="autoSample.transfusionType" placeholder="请选择输血成分" filterable >
                        <el-option v-for="item in optionTransfusionType" :key="item.code" :label="item.name"
                                   :value="item.code" width="50px">
                        </el-option>
                    </el-select></el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请输血量
                        </template>
                        <el-form-item prop="transfusionVolume">
                        <el-select v-model="autoSample.transfusionVolume" placeholder="请选择输血成分" filterable >
                            <el-option v-for="item in bloodSizeList" :key="item.code" :label="item.size"
                                       :value="item.code" width="50px">
                            </el-option>
                        </el-select></el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            拟手术日期
                        </template>
                        <el-form-item prop="surgeryTime">
                        <el-date-picker
                                v-model="autoSample.surgeryTime"
                                type="date"
                                placeholder="选择日期"
                                size="small"
                                format="yyyy-MM-dd HH:mm:ss"
                                value-format="yyyy-MM-dd HH:mm:ss">

                        </el-date-picker></el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            体重
                        </template>
                        <el-form-item prop="weight">
                            <el-input placeholder="请输入体重(kg)" v-model="autoSample.weight"></el-input></el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血小板计数
                        </template>
                        <el-form-item prop="plateletCount">
                        <el-input placeholder="血小板计数" v-model="autoSample.plateletCount"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血红蛋白
                        </template>
                        <el-form-item prop="hemoglobin">
                        <el-input placeholder="血红蛋白" v-model="autoSample.hemoglobin"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            红细胞比容
                        </template>
                        <el-form-item prop="hematocrit">
                        <el-input placeholder="红细胞比容" v-model="autoSample.hematocrit"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请医师
                        </template>
                        <el-form-item prop="applyDoctor">
                        <el-input placeholder="请输入申请医师" v-model="autoSample.applyDoctor" @focus="getAutoUser()"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请日期
                        </template>
                        <el-form-item prop="applyTime">
                        <el-date-picker
                                v-model="autoSample.applyTime"
                                type="date"
                                placeholder="选择日期"
                                size="small"
                                format="yyyy-MM-dd HH:mm:ss"
                                value-format="yyyy-MM-dd HH:mm:ss">
                        </el-date-picker></el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            鉴定血型
                        </template>
                        <el-form-item prop="identifyBloodType">
                        <el-select v-model="autoSample.identifyBloodType"  filterable >
                            <el-option v-for="item in optionAboType" :key="item.code" :label="item.name"
                                       :value="item.code" width="50px">
                            </el-option>
                        </el-select></el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            鉴定Rho
                        </template>
                        <el-form-item prop="identifyRho">
                        <el-select v-model="autoSample.identifyRho"  filterable >
                            <el-option v-for="item in optionRhType" :key="item.code" :label="item.name"
                                       :value="item.code" width="50px">
                            </el-option>
                        </el-select>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            鉴定者
                        </template>
                        <el-form-item prop="appraiser">
                            <el-input placeholder="请输入鉴定者" v-model="autoSample.appraiser"></el-input></el-form-item>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            回输时间
                        </template>
                        <el-form-item prop="backTime">
                        <el-date-picker
                                v-model="autoSample.backTime"
                                type="date"
                                placeholder="选择日期"
                                size="small"
                                format="yyyy-MM-dd HH:mm:ss"
                                value-format="yyyy-MM-dd HH:mm:ss">
                        </el-date-picker></el-form-item>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            回输量
                        </template>
                        <el-form-item prop="backVolume">
                        <el-input  v-model="autoSample.backVolume"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            取血人
                        </template>
                        <el-form-item prop="bloodTaker">
                            <el-input  v-model="autoSample.bloodTaker"></el-input></el-form-item>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            发血人
                        </template>
                        <el-form-item prop="bloodSender">
                        <el-input  v-model="autoSample.bloodSender"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            采血者
                        </template>
                        <el-form-item prop="bloodCollector">
                        <el-input  v-model="autoSample.bloodCollector"></el-input>
                        </el-form-item>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            心功能
                        </template>
                        <el-form-item prop="heartFunction">
                        <el-input  v-model="autoSample.heartFunction"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            肺功能
                        </template>
                        <el-form-item prop="lungFunction">
                        <el-input  v-model="autoSample.lungFunction"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            肝功能
                        </template>
                        <el-form-item prop="liverFunction">
                        <el-input  v-model="autoSample.liverFunction"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            肾功能
                        </template>
                        <el-form-item prop="renalFunction">
                        <el-input  v-model="autoSample.renalFunction"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            自体输血同意书
                        </template>
                        <el-form-item prop="isAutobloodtranAgreement">
                        <el-select v-model="autoSample.isAutobloodtranAgreement">
                            <el-option label="是" value="1"></el-option>
                            <el-option label="否" value="0"></el-option>
                        </el-select></el-form-item>
                    </el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            备注
                        </template>
                        <el-form-item prop="note">
                        <el-input placeholder="请输入备注" v-model="autoSample.note"></el-input>
                        </el-form-item></el-descriptions-item>
                </el-descriptions>
            </el-form>

            <!-- 底部区域 -->
            <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel()">取 消</el-button>
                    <el-button type="primary" @click="saveAuto">申 请</el-button>
                </span>
        </el-dialog>

        <el-dialog title="术中输血申请" center :visible.sync="dialogSurgeyVisible" width="75%" @close="cancel" >
            <!-- 内容的主体区域 -->
            <el-form ref="form" :model="surgeySample" :rules="surFormRules">
                <el-descriptions   :content-style="rowCenter" :label-style="rowCenter" class="margin-top"  :column="3"  :size="size" border>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            病历号
                        </template>
                        <el-form-item prop="medicalRecordNumber">
                            <el-input placeholder="请输入病历号" v-model="surgeySample.medicalRecordNumber" @change="getSurIdcard()"></el-input>
                        </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            身份证号
                        </template>
                <el-form-item prop="patientIdcard">
                    <el-input placeholder="请输入受血者身份证号" v-model="surgeySample.patientIdcard" maxlength="18"  show-word-limit ></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            ABO血型
                        </template>
                <el-form-item prop="aboBloodType">
                    <el-select  v-model="surgeySample.aboBloodType" placeholder="请选择血型" filterable>
                        <el-option v-for="item in optionAboType" :key="item.code" :label="item.name"
                        :value="item.code" width="50px">
                        </el-option>
                    </el-select>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            Rh血型
                        </template>
                <el-form-item  prop="rhBloodType">
                    <el-select v-model="surgeySample.rhBloodType" placeholder="请选择血型" filterable >
                        <el-option v-for="item in optionRhType" :key="item.code" :label="item.name"
                                   :value="item.code" width="50px">
                        </el-option>
                    </el-select>
                </el-form-item></el-descriptions-item>
                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            临床诊断
                        </template>
                <el-form-item prop="clinicalDiagnosis">
                    <el-select v-model="surgeySample.clinicalDiagnosis" placeholder="请选择临床诊断" filterable >
                        <el-option v-for="(item,index) in optionDiagnosis" :key="index" :label="item.name"
                                   :value="item.name" width="50px">
                        </el-option>
                    </el-select>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            输血目的
                        </template>
                <el-form-item prop="transfusionPurpose">
                    <el-input v-model="surgeySample.transfusionPurpose" style="width:250px"></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            自体输血时间
                        </template>
                <el-form-item prop="autologousTransfusionTime">
                    <el-date-picker
                            v-model="surgeySample.autologousTransfusionTime"
                            type="date"
                            placeholder="选择日期"
                            size="small"
                            format="yyyy-MM-dd HH:mm:ss"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            style="width:250px">
                    </el-date-picker>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            自体血回收量
                        </template>
                <el-form-item prop="autologousRecycleVolume">
                    <el-input v-model="surgeySample.autologousRecycleVolume" style="width:250px"></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血液稀释量
                        </template>
                <el-form-item prop="bloodDilution">
                    <el-input v-model="surgeySample.bloodDilution" style="width:250px"></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            血液单位
                        </template>
                <el-form-item  prop="bloodUnit">
                    <el-input v-model="surgeySample.bloodUnit" style="width:250px"></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            操作者
                        </template>
                <el-form-item  prop="operator">
                    <el-input v-model="surgeySample.operator" style="width:250px" @focus="getSurUser()"></el-input>
                </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            操作日期
                        </template>
                    <el-form-item >
                        <el-date-picker
                                v-model="surgeySample.operationTime"
                                type="date"
                                placeholder="选择日期"
                                size="small"
                                format="yyyy-MM-dd HH:mm:ss"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                style="width:250px">
                        </el-date-picker>
                    </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            申请血量
                        </template>
                        <el-form-item  prop="transfusionVolume">
                            <el-select v-model="surgeySample.transfusionVolume" placeholder="请选择输血量" filterable >
                                <el-option v-for="item in bloodSizeList" :key="item.code" :label="item.size"
                                           :value="item.code" width="50px">
                                </el-option>
                            </el-select>
                        </el-form-item></el-descriptions-item>

                    <el-descriptions-item>
                        <template slot="label" align="center" >
                            输血成分
                        </template>
                        <el-form-item prop="transfusionType">
                            <el-select v-model="surgeySample.transfusionType" placeholder="请选择输血成分" filterable >
                                <el-option v-for="item in optionTransfusionType" :key="item.code" :label="item.name"
                                           :value="item.code" width="50px">
                                </el-option>
                            </el-select>
                        </el-form-item></el-descriptions-item>
                </el-descriptions> </el-form>

            <!-- 底部区域 -->
                    <span slot="footer" class="dialog-footer">
                    <el-button @click="cancel()">取 消</el-button>
                    <el-button type="primary" @click="saveSurgey">申 请</el-button>
                    </span>
        </el-dialog>



        <el-table ref="transfusionTable" :data="tableData" style="width: 100%" border
                  :header-cell-style="{'text-align': 'center','background': '#eef1f6'}" highlight-current-row>

            <el-table-column type="selection" width="55" align="center"></el-table-column>

            <el-table-column prop="medicalRecordNumber" label="病历号" width="200" align="center" fixed="left">
                <template slot-scope="scope">
                    <!--scope.row  会获取当前ID行记录-->
                    <el-button type="text" @click="viewInfo(scope.row)" >{{scope.row.medicalRecordNumber}}</el-button>
                </template>
            </el-table-column>

            <el-table-column prop="idcard" label="身份证号" width="180" align="center">
            </el-table-column>
            <el-table-column prop="name" label="姓名" width="180" align="center">
            </el-table-column>
            <el-table-column prop="gender" label="性别" width="180" align="center">
            </el-table-column>

            <el-table-column prop="age" label="年龄" width="180" align="center">
            </el-table-column>

            <el-table-column prop="nationality" label="民族" width="100" align="center">
                <template slot-scope="scope">
                    {{ getNationalityName(scope.row.nationality)}}
                </template>
            </el-table-column>
            <el-table-column prop="department" label="科别" width="130" align="center">
            </el-table-column>
            <el-table-column prop="bedNumber" label="床号" width="130" align="center">
            </el-table-column>
            <el-table-column prop="medicalHistory" label="既往病史" width="130" align="center">
            </el-table-column>
            <el-table-column prop="tansfusionHistory" label="既往输血史" width="130" align="center">
            </el-table-column>
            <el-table-column prop="prengancy" label="孕次数" width="130" align="center">
            </el-table-column>
            <el-table-column prop="production" label="产次数" width="130" align="center">
            </el-table-column>
            <el-table-column prop="territorial" label="属地" width="130" align="center">
            </el-table-column>
            <el-table-column prop="unit" label="单位" width="130" align="center">
                            </el-table-column>
            </el-table-column>
            <el-table-column label="操作" width="140" align="center" fixed="right">
                <template slot-scope="scope">
                    <el-button size="mini" type="danger" @click="handleEdit(scope.$index, scope.row)">修改
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <!--分页组件-->
        <div class="pagination-container">
        <el-pagination :page-sizes="[5,10,20]"
                       :page-size="pagination.pageSize"
                       :total="pagination.total"
                       :current-page="pagination.currentPage"
                       @current-change="handleCurrentChange"
                       @size-change="handleSizeChange"
                       layout="total,sizes,prev, pager, next, jumper"
                       class="pagination"
                       style="text-align: center; margin-top: 20px;">
        </el-pagination>
        </div>

    </template>
</div>
<!--<input type="text" id="a"/>-->


<script src="/icons/iconfont.js"></script>
<script src="/plugins/vue-2.6.11/vue.js"></script>
<script src="/plugins/element-2.4.5/index.js"></script>
<script src="/js/httpVueLoader.js"></script>
<script src="/js/jquery.min.js"></script>
<script src="/node_modules/element-china-area-data/dist/app.js"></script>





<script>Vue.prototype.$ELEMENT = { size: 'medium' };</script>
<script type="text/javascript">
    $(function(){
        $("#a").bind('input porpertychange',function(){
            console.log("e");
        });
    });
</script>
<!--<script type="module" src="../pages/element-china-area-data/src/app.js"></script>-->
<script type="module">

    (function () {
        const vm = window.vm = new Vue({
            el: '.data-manage-table',
            // name: "app",


            data() {
                //身份证校验
                const checkIdNum = (rule, value, callback) => {
                    if (!value) {
                        return callback(new Error('身份证不能为空'))
                    }
                    if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
                        callback(new Error('请输入正确的二代身份证号码'))
                    } else {
                        callback()
                    }
                }
                //纯中文校验
                const validateContacts = (rule, value, callback) => {
                    if (!value) {
                        return callback(new Error('请输入中文'))
                    }
                    if (!/^[\u0391-\uFFE5A-Za-z]+$/.test(value)) {
                        callback(new Error('不可输入特殊字符'))
                    } else {
                        callback()
                    }
                }
                //纯数字校验
                const validateNumber = (rule, value, callback) => {
                    let numberReg = /^\d+$|^\d+[.]?\d+$/
                    if (value !== '') {
                        if (!numberReg.test(value)) {
                            callback(new Error('请输入数字'))
                        } else {
                            callback()
                        }
                    } else {
                        callback(new Error('请输入值'))
                    }
                }
                return {
                    text: '',
                    rowCenter: {
                        "text-align": "center"
                    },
                    //省市区三级联动
                    options: regionData,
                    selectedOptions: [],


                    activeNames: ['1'],
                    //民族选项
                    optionNationality: [],
                    //ABO选项
                    optionAboType: [],
                    //Rh选项
                    optionRhType: [],

                    optionTransfusionType: [],
                    //科室选项
                    childDepartmentGroups: [],
                    parentDepartmentGroups: [],
                    //临床诊断选项
                    optionDiagnosis: [],
                    input3: '',

                    size: '',

                    code1: '',
                    options1: [{
                        value: '1',
                        label: '是'
                    }, {
                        value: '0',
                        label: '否'
                    }],
                    page: {},
                    name: '',
                    pageNum: 1,
                    pageSize: 10,
                    form: {},
                    //分页相关信息
                    pagination: {
                        currentPage: 1,
                        pageSize: 5,
                        total: 0,
                        //查询条件
                        name: '',
                        medicalRecordNumber: '',
                        idcard: '',
                    },

                    location: [{
                        value: '男',
                        label: '男'
                    }, {
                        value: '女',
                        label: '女'
                    }],

                    //弹出框显示
                    dialogVisible: false,
                    dialogUpdateVisible: false,
                    dialogClinicVisible: false,
                    dialogAutoVisible: false,
                    dialogTranVisible: false,
                    dialogSurgeyVisible: false,
                    dialogPatientVisible: false,

                    searchSample: {
                        name: '',
                        medicalRecordNumber: '',
                        patientIdcard: '',
                    },

                    departmentSample: {
                        code: '',
                        name: '',
                        parentCode: '',
                    },
                    bloodSizeList: [],
                    //操作用户
                    user: {
                        "username": "",
                        "jobnum": "",
                    },


                    clinicSample: {
                        medicalRecordNumber: '',
                        //transfusionNumber:'',
                        patientIdcard: '',
                        clinicalDiagnosis: '',
                        transfusionPurpose: '',
                        transfusionType: '',
                        transfusionVolume: '',
                        scheduledTransfusionTime: '',
                        isIrradiationBlood: '',
                        isFilteringBlood: '',
                        isRecheck: '',
                        acceptSampleTime: '',
                        applyDoctor: '',
                        attendingPhysician: '',
                        applyTime: '',
                        isSignConsentForm: '',
                        recipientSpecimen: '',
                        receiveSampleTime: '',
                    },
                    autoSample: {
                        //transfusionNumber: '',
                        medicalRecordNumber: '',
                        patientIdcard: '',
                        diagnosisResult: '',
                        transfusionType: '',
                        //prepareVolume: '',
                        surgeryTime: '',
                        weight: '',
                        plateletCount: '',
                        hemoglobin: '',
                        hematocrit: '',
                        applyDoctor: '',
                        applyTime: '',
                        identifyBloodType: '',
                        identifyRho: '',
                        appraiser: '',
                        backTime: '',
                        backVolume: '',
                        bloodTaker: '',
                        bloodSender: '',
                        bloodCollector: '',
                        heartFunction: '',
                        lungFunction: '',
                        liverFunction: '',
                        renalFunction: '',
                        isAutobloodtranAgreement: '',
                        note: '',
                        transfusionVolume: '',

                    },
                    bloodSample: {
                        bloodType: '',
                        rhd: '',
                        alt: '',
                        rbc: '',
                        hbsag: '',
                        hb: '',
                        hcv: '',
                        hiv: '',
                        plt: '',
                        rpr: '',
                        state: '',
                        reviewerName: '',
                        reviewerNumber: '',
                        reviewTime: '',
                    },
                    surgeySample: {
                        //transfusionNumber: '',
                        medicalRecordNumber: '',
                        patientIdcard: '',
                        aboBloodType: '',
                        rhBloodType: '',
                        clinicalDiagnosis: '',
                        transfusionPurpose: '',
                        autologousTransfusionTime: '',
                        autologousRecycleVolume: '',
                        bloodDilution: '',
                        bloodUnit: '',
                        operator: '',
                        operationTime: '',
                        transfusionVolume: '',
                        transfusionType: '',
                    },
                    bloodTestSample: {
                        inspectionSheet: '',
                    },
                    //表格信息
                    tableData: [],
                    //
                    // 新增患者信息
                    addForm: {
                        //medicalRecordNumber: '',
                        idcard: '',
                        name: '',
                        gender: '',
                        age: 1,
                        nationality: '',
                        department: '',
                        bedNumber: '',
                        medicalHistory: '',
                        tansfusionHistory: '',
                        prengancy: '',
                        production: '',
                        territorial: '',
                        unit: '',
                    },
                    //修改患者信息表单证
                    updateForm: {
                        id: '',
                        //medicalRecordNumber: '',
                        idcard: '',
                        name: '',
                        gender: '',
                        age: 1,
                        nationality: '',
                        department: '',
                        bedNumber: '',
                        medicalHistory: '',
                        tansfusionHistory: '',
                        prengancy: '',
                        production: '',
                        territorial: '',
                        unit: '',
                    },
                    //自体输血申请表单验证
                    autoFormRules: {
                        medicalRecordNumber: [
                            {required: true, message: '请输入病历号', trigger: 'blur'},
                        ],
                        patientIdcard: [{
                            required: true,
                            message: "身份证号码不能为空",
                            trigger: "blur"
                        }, {
                            validator: checkIdNum,
                            trigger: 'blur'
                        },],
                        diagnosisResult: [
                            {required: true, message: '请选择临床诊断', trigger: 'blur'},

                        ],
                        transfusionType: [
                            {required: true, message: '请选择输血成分', trigger: 'blur'},

                        ],
                        transfusionVolume: [
                            {required: true, message: '请输入申请血量', trigger: 'change'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        surgeryTime: [
                            {required: true, message: '请选择拟手术日期', trigger: 'blur'},

                        ],
                        weight: [
                            {required: true, message: '请输入体重', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        plateletCount: [
                            {required: true, message: '请输入血小板计数', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        hemoglobin: [
                            {required: true, message: '请输入血红蛋白', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        hematocrit: [
                            {required: true, message: '请输入红细胞比容', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        applyDoctor: [
                            {required: true, message: '请输入申请医生', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        applyTime: [
                            {required: true, message: '请选择申请时间', trigger: 'blur'},
                        ],
                        identifyBloodType: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        identifyRho: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        appraiser: [
                            {required: true, message: '请输入鉴定者', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        backTime: [
                            {required: true, message: '请选择申请时间', trigger: 'blur'},
                        ],
                        backVolume: [
                            {required: true, message: '请输入申请血量', trigger: 'change'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        bloodTaker: [
                            {required: true, message: '请输入取血人', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        bloodSender: [
                            {required: true, message: '请输入发血人', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        bloodCollector: [
                            {required: true, message: '请输入采血人', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        heartFunction: [
                            {required: true, message: '请输入心功能', trigger: 'blur'},
                        ],
                        lungFunction: [
                            {required: true, message: '请输入肺功能', trigger: 'blur'},
                        ],
                        liverFunction: [
                            {required: true, message: '请输入肝功能', trigger: 'blur'},
                        ],
                        renalFunction: [
                            {required: true, message: '请输入肾功能', trigger: 'blur'},
                        ],
                        isAutobloodtranAgreement: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        transfusionType: [
                            {required: true, message: '请选择输血成分', trigger: 'blur'},
                        ],


                    },
                    //术中输血表单验证
                    surFormRules: {
                        medicalRecordNumber: [
                            {required: true, message: '请输入病历号', trigger: 'blur'},
                        ],
                        patientIdcard: [{
                            required: true,
                            message: "身份证号码不能为空",
                            trigger: "blur"
                        }, {
                            validator: checkIdNum,
                            trigger: 'blur'
                        },],
                        aboBloodType: [
                            {required: true, message: '请选择', trigger: 'blur'},

                        ],
                        rhBloodType: [
                            {required: true, message: '请选择', trigger: 'blur'},

                        ],
                        clinicalDiagnosis: [
                            {required: true, message: '请选择临床诊断', trigger: 'change'},

                        ],
                        transfusionPurpose: [
                            {required: true, message: '请输入输血目的', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        autologousTransfusionTime: [
                            {required: true, message: '请输入自体血时间', trigger: 'blur'},

                        ],
                        autologousRecycleVolume: [
                            {required: true, message: '请输入自体血回收量', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        bloodDilution: [
                            {required: true, message: '请输入床号', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        bloodUnit: [
                            {required: true, message: '请输入血液单位', trigger: 'blur'},

                        ],
                        operator: [
                            {required: true, message: '请输入操作者', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        operationTime: [
                            {required: true, message: '请选择申请时间', trigger: 'blur'},
                        ],
                        transfusionVolume: [
                            {required: true, message: '请选择申请输血量', trigger: 'blur'},
                        ],
                        transfusionType: [
                            {required: true, message: '请选择输血成分', trigger: 'blur'},
                        ],


                    },
                    //临床输血申请表单验证
                    clinicFormRules: {
                        medicalRecordNumber: [
                            {required: true, message: '请输入病历号', trigger: 'blur'},
                        ],
                        patientIdcard: [{
                            required: true,
                            message: "身份证号码不能为空",
                            trigger: "blur"
                        }, {
                            validator: checkIdNum,
                            trigger: 'blur'
                        },],
                        clinicalDiagnosis: [
                            {required: true, message: '请输入临床诊断', trigger: 'blur'},

                        ],
                        transfusionPurpose: [
                            {required: true, message: '请输入输血目的', trigger: 'change'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        transfusionType: [
                            {required: true, message: '请输入输血成分', trigger: 'blur'},
                        ],
                        transfusionVolume: [
                            {required: true, message: '请输入', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        scheduledTransfusionTime: [
                            {required: true, message: '请输入', trigger: 'blur'},
                        ],
                        isIrradiationBlood: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        isFilteringBlood: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        isRecheck: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        acceptSampleTime: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        applyDoctor: [
                            {required: true, message: '请输入申请医生', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        attendingPhysician: [
                            {required: true, message: '请输入主治医师', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        applyTime: [
                            {required: true, message: '请输入', trigger: 'blur'},
                        ],
                        isSignConsentForm: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        recipientSpecimen: [
                            {required: true, message: '请选择', trigger: 'blur'},
                        ],
                        receiveSampleTime: [
                            {required: true, message: '请输入接收标本时间', trigger: 'blur'},
                        ],

                    },
                    //新增患者表单验证
                    addFormRules: {
                        medicalRecordNumber: [
                            {required: true, message: '请输入病历号', trigger: 'blur'},
                        ],
                        idcard: [{
                            required: true,
                            message: "身份证号码不能为空",
                            trigger: "blur"
                        }, {
                            validator: checkIdNum,
                            trigger: 'blur'
                        },],
                        name: [
                            {required: true, message: '请输入姓名', trigger: 'blur'},
                            {
                                validator: validateContacts,
                                trigger: "blur"
                            }
                        ],
                        gender: [
                            {required: true, message: '请输入性别', trigger: 'change'},
                        ],
                        age: [
                            {required: true, message: '请输入年龄', trigger: 'blur'},
                            {
                                validator: validateNumber,
                                trigger: "blur"
                            }
                        ],
                        nationality: [
                            {required: true, message: '请输入国籍', trigger: 'blur'},
                        ],
                        department: [
                            {required: true, message: '请输入科别', trigger: 'blur'},
                        ],
                        bedNumber: [
                            {required: true, message: '请输入床号', trigger: 'blur'},
                            {min:1,max:5,message: '长度在1~5个字符'},
                        ],
                        medicalHistory: [
                            {required: true, message: '请输入既往病史', trigger: 'blur'},
                        ],
                        tansfusionHistory: [
                            {required: true, message: '请输入既往输血史', trigger: 'blur'},
                        ],
                        prengancy: [
                            {required: true, message: '请输入孕次数', trigger: 'blur'},
                        ],
                        production: [
                            {required: true, message: '请输入产次数', trigger: 'blur'},
                        ],
                        territorial: [
                            {required: true, message: '请输入属地', trigger: 'blur'},
                        ],
                        unit: [
                            {required: true, message: '请输入单位', trigger: 'blur'},
                        ],
                    }
                }

            },




            created() {
                //this.test();
                //this.loadTable(this.pageNum);
                this.getByQueryPage();
               // this.selectedOptions = [this.form1.provinceCode, this.form.cityCode, this.form1.areaCode];

            },
            mounted() {
                this.getNationality();
                this.getNationalityName();
                this.getABOtype();
                this.getRhType();
                this.getTypeList();
                this.getAllDepartment();
                this.getDiagnosis();
                this.getSizeList();
                this.getPName();
                this.user = sessionStorage.getItem("user") ? JSON.parse(sessionStorage.getItem("user")) : {};
            },
            methods: {



                //计数控件

                handleChange(value) {
                    console.log(value);
                },
                handleDelete(index, row) {
                    console.log(index, row);
                },
                //分页查询
                handleSizeChange: function (pageSize) {
                    this.pagination.pageSize = pageSize;
                    this.getByQueryPage(1)
                },
                handleCurrentChange: function (currentPage) {
                    this.pagination.currentPage = currentPage;//执行查询
                    this.getByQueryPage(1);

                },
                //获取当前选择要修改的患者信息
                handleEdit(index, row) {
                    this.form = {}
                    console.log(index, row);
                    this.updateForm = row
                    console.log(this.updateForm)

                    this.dialogUpdateVisible = true
                },


                loadTable(num) {
                    this.pageNum = num;
                    $.get("/patient/normal/list").then(res => {
                        this.tableData = res.data.records;
                        console.log(res.data.records);
                    });
                },


                //分页查询 按条件查询
                getByQueryPage: function (flag) {

                    if (flag !== 1) {
                        this.pagination.name = '';
                        this.pagination.medicalRecordNumber = '';
                        this.pagination.idcard = '';
                        this.pagination.currentPage = 1
                    }
                    axios.get('/patient/normal/' + this.pagination.currentPage + '/' + this.pagination.pageSize,
                        {
                            params: {
                                name: this.pagination.name,
                                medicalRecordNumber: this.pagination.medicalRecordNumber,
                                idcard: this.pagination.idcard,
                            }
                        }).then(res => {
                        if (res.data.code === 200) {
                            this.pagination.pageSize = res.data.data.size;
                            this.pagination.currentPage = res.data.data.current;
                            this.pagination.total = res.data.data.total;
                            this.tableData = res.data.data.records;
                            // }else{
                            //     this.$message.error("查询失败")
                        }
                    })
                },
                //省市区三级联动
                handleChange1() {
                    let loc = "";
                    for (let i = 0; i < this.selectedOptions.length; i++) {
                        loc += CodeToText[this.selectedOptions[i]];
                    }
                    console.log(loc)
                    this.addForm.territorial=loc;
                    this.updateForm.territorial=loc;
                    //alert(loc);
                },




                //修改患者信息
                updatePatient() {

                    console.log(this.updateForm.territorial)

                    let data = JSON.stringify(this.updateForm);

                    console.log(data)
                    $.ajax({
                        url: '/patient/normal/update',
                        type: 'put',
                        contentType: 'application/json',
                        data: data
                    }).then(res => {
                        if (res) {
                            this.$message.success("保存成功")
                            this.dialogUpdateVisible = false
                            this.loadTable(1);
                        } else {
                            this.$message.error("保存失败")
                        }
                        this.loadTable(1);
                    })

                },


                //点击新增弹出患者信息新增弹窗
                add() {
                    this.dialogVisible = true;
                    this.form = {};
                },
                //保存新增患者信息
                save() {
                    let data = JSON.stringify(this.addForm);

                    console.log(data)
                        // 新增
                        $.ajax({
                            url: '/patient/normal/addpatient',
                            type: 'post',
                            contentType: 'application/json',
                            data: data
                        }).then(res => {
                            this.dialogVisible = false;
                            this.loadTable(1);
                        })

                },
                //获取输血成分类型字典
                getTypeList() {
                    $.ajax({
                        url: '/transfusionType/normal/type',
                        type: 'get',
                        contentType: 'application/json',
                    }).then(res => {
                        this.optionTransfusionType = res
                        console.log(res)
                    })
                },
                //获取输血申请量字典
                getSizeList() {
                    $.ajax({
                        url: '/bloodSize/normal/getName',
                        type: 'get',
                        contentType: 'application/json',
                    }).then(res => {
                        this.bloodSizeList = res
                        console.log(res)
                    })
                },
                //获取民族数据字典
                getNationality() {
                    $.ajax({
                        url: '/nationality/normal/query',
                        type: 'get',
                        contentType: 'application/json',
                    }).then(res => {
                        this.optionNationality = res
                    })
                },
                //code转name显示
                getNationalityName(code) {
                    for (let i = 0; i < this.optionNationality.length; i++) {
                        if (this.optionNationality[i].code === code) {
                            return this.optionNationality[i].name;

                        }
                    }

                },
                // ABO血型字典
                getABOtype() {
                    $.ajax({
                        url: '/aboType/normal/type',
                        type: 'get',
                        contentType: 'application/json',
                    }).then(res => {
                        this.optionAboType = res ? res : {}
                    })
                },
                //将数据字典code转为name
                getABOName(code) {
                    for (let i = 0; i < this.optionAboType.length; i++) {
                        if (this.optionAboType[i].code === code) {
                            return this.optionAboType[i].name;
                        }
                    }

                },

                // Rh血型字典
                getRhType() {
                    $.ajax({
                        url: '/rhType/normal/type',
                        type: 'get',
                        contentType: 'application/json',
                    }).then(res => {
                        this.optionRhType = res ? res : {}
                    })
                },
                //将数据字典code转为name
                getRhName(code) {
                    for (let i = 0; i < this.optionRhType.length; i++) {
                        if (this.optionRhType[i].code === code) {
                            return this.optionRhType[i].name;
                        }
                    }

                },

                //获取临床诊断数据字典
                getDiagnosis() {
                    $.ajax({
                        url: '/diagnosis/normal/query',
                        type: 'get',
                        contentType: 'application/json',
                    }).then(res => {
                        this.optionDiagnosis = res
                    })
                },
                //获取一级科室数据字典
                getAllDepartment() {
                    console.log("一级科室")
                    $.ajax({
                        url: '/department/normal/list',
                        type: 'get',
                        contentType: 'application/json',
                    }).then(res => {
                            this.parentDepartmentGroups = res
                            console.log(res)
                        }
                    )
                },
                //根据一级科室获取二级科室
                getDcode() {
                    console.log(11111111)
                    this.code1 = this.departmentSample.code
                    axios.get('/department/normal/query', {
                        params: {
                            code1: this.code1,
                        },
                    }).then(res => {
                        console.log(res.data)
                        if (res.data[0]!=null){
                            this.childDepartmentGroups = res.data

                        }else{
                            console.log(this.departmentSample.code)
                            this.addForm.department=this.getPName(this.departmentSample.code)
                            console.log(this.addForm.department)
                        }
                        }
                    )
                },
                getPName(code){
                    for (let i = 0; i < this.parentDepartmentGroups.length; i++) {
                        if (this.parentDepartmentGroups[i].code === code) {
                            return this.parentDepartmentGroups[i].name;
                        }
                    }
                },
                getUser() {
                    this.clinicSample.applyDoctor = this.user.username
                },
                getAutoUser() {
                    this.autoSample.applyDoctor = this.user.username
                },
                getSurUser() {
                    this.surgeySample.operator = this.user.username
                },

                //提交临床输血申请
                saveClinic(applicantId) {
                    applicantId = this.user.jobnum
                    let data = JSON.stringify(this.clinicSample);
                    console.log(data)
                    // 新增
                    $.ajax({
                        url: '/transfusionClinic/normal/addformdata?applicantId='+applicantId,
                        type: 'post',
                        contentType: 'application/json',
                        data: data
                    }).then(res => {
                        this.dialogClinicVisible = false;
                        this.dialogTranVisible = false;
                        this.loadTable(1);
                    })
                },

                //提交自体输血申请
                saveAuto(applicantId) {
                    applicantId = this.user.jobnum
                    let data = JSON.stringify(this.autoSample);
                    console.log(data)
                    // 新增
                    $.ajax({
                        url: '/transfusionAutologous/normal/addformdata?applicantId='+applicantId,
                        type: 'post',
                        contentType: 'application/json',
                        data: data
                    }).then(res => {
                        this.dialogAutoVisible = false;
                        this.dialogTranVisible = false;
                        this.loadTable(1);
                    })
                },
                //提交术中自体输血申请
                saveSurgey(applicantId) {

                    applicantId=this.user.jobnum
                    let data = JSON.stringify(this.surgeySample);
                        // 新增
                        $.ajax({
                            url: '/transfusionSurgey/normal/addformdata?applicantId='+applicantId,
                            // url: '/transfuisonSurgey/normal/addformdata',
                            type: 'post',
                            contentType: 'application/json',
                            data: data
                        }).then(res => {
                            console.log(1111111111)
                            console.log(res.data)
                            this.dialogSurgeyVisible = false;
                            this.dialogTranVisible = false;
                            this.loadTable(1);
                        })
                },


                //点击输血申请选择申请类型
                transfusion() {
                    this.dialogTranVisible = true;
                },
                clinic() {
                    this.dialogClinicVisible = true;
                },
                auto() {
                    this.dialogAutoVisible = true;
                },
                surgey() {
                    this.dialogSurgeyVisible = true;
                },
                //点击病人病案号显示病人信息
                viewInfo(row) {
                    this.dialogPatientVisible = true;
                    this.addForm = row
                    this.addForm = JSON.parse(JSON.stringify(row))
                },


                //批量删除
                batchDelete() {
                    if (JSON.parse(JSON.stringify(this.$refs.transfusionTable.selection)).length === 0) {
                        this.$notify({
                            title: '温馨提示：',
                            message: '您未选中数据，请重新操作！！！',
                            type: 'warning'
                        });
                        return;
                    }
                    let checkArr = JSON.parse(JSON.stringify(this.$refs.transfusionTable.selection));  // 存储了勾选到的数据
                    var ids = new Array()
                    for (var i = 0; i < checkArr.length; i++) {
                        ids[i] = checkArr[i].id;
                    }
                    console.log("打印所选编号")
                    console.log(ids)
                    // let data={ids:ids}
                    //批量删除
                    this.$confirm('确定删除这些数据吗, 是否继续?', '批量删除', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        axios({
                            url: '/patient/normal/batchDelete',
                            method: 'put',
                            dataType: 'json',
                            data: ids
                        }).then(res => {
                            console.log(res.data.code)
                            if (res.data.code === 200) {
                                this.$notify({
                                    tile: '温馨提示',
                                    message: '批量删除成功！！！',
                                    type: 'success'
                                })
                                this.getByQueryPage(0);
                            } else {
                                this.$notify({
                                    tile: '警告',
                                    message: '删除出错',
                                    type: 'warning'
                                })
                            }
                        }).catch(err => {
                            this.$notify.error({
                                title: '错误',
                                message: '删除失败',
                            })
                        });
                    }).catch(() => {
                        this.$message({
                            type: 'info',
                            message: '已取消删除'
                        });
                    });
                },


                //输入患者检验单号自动回填血液检验信息
                bloodInfo() {
                    console.log(this.bloodTestSample.inspectionSheet)
                    $.post("/transfusionClinic/normal/applyList2", {inspectionSheet: this.bloodTestSample.inspectionSheet}).then(res => {
                        this.bloodSample = JSON.parse(JSON.stringify(res.data[0]))
                        console.log(this.bloodSample)
                        console.log(res)
                    });
                },
                //
                getIdcard(){
                    $.get("/transfusionAutologous/normal/getIdcard" ,{
                        medicalRecordNumber:this.autoSample.medicalRecordNumber
                    }).then(res =>{
                        console.log(res.data)
                        this.autoSample.patientIdcard=res.data

                });
                },
                getClinicIdcard(){
                    $.get("/transfusionClinic/normal/getIdcard" ,{
                        medicalRecordNumber:this.clinicSample.medicalRecordNumber
                    }).then(res =>{
                        console.log(res.data)
                        this.clinicSample.patientIdcard=res.data

                    });
                },
                getSurIdcard(){
                    $.get("/transfusionClinic/normal/getIdcard" ,{
                        medicalRecordNumber:this.surgeySample.medicalRecordNumber
                    }).then(res =>{
                        console.log(res.data)
                        this.surgeySample.patientIdcard=res.data

                    });
                },


                close() {
                    this.dialogPatientVisible = false;
                },
                //取消按钮
                cancel() {
                    this.addForm = ''
                    this.selectedOptions=''
                    this.clinicSample = ''
                    this.surgeySample = ''
                    this.autoSample = ''
                    this.dialogVisible = false
                    this.dialogClinicVisible = false
                    this.dialogAutoVisible = false
                    this.dialogSurgeyVisible = false

                }
            }

        });
    })()
</script>
</body>
</html>